<?php

class Core_Backend_Component_Resource_View_Subject_Poi_Assign extends Core_Backend_Share_View_Form {

	protected function initialize(){
		parent::initialize();
		$this->setTemplatePath('assign');
	}

    protected function buildToolbar($toolbar) {
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('resource/subject/poi-list'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.save'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'poi-assign')."')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $form->setAction($this->getUrl())
                ->setId('road_form')
                ->addHiddenField('subjectid', 'subjectid', $this->getSubject()->getId());
        $form->addDatetimeField($this->__('share.label.start_time'), 'assign_start_time', 'assign[start_time]', TRUE)
                ->setFormat('Y-m-d')
                ->setCurrentDate();
        $form->addDatetimeField($this->__('share.label.end_time'), 'assign_end_time', 'assign[end_time]', TRUE)
                ->setFormat('Y-m-d');
        $form->addPoiBrowserField($this->__('resource.label.assign_poi'), 'pois', 'assign[pois][]', TRUE)
                ->addValidateRule('required');
        parent::buildForm($form);
    }
}